import http from '@/libs/http'
// 菜单列表接口
export const pageList = (params) => {
  return new Promise((resolve, reject) => {
    http.fetchGet('admin/menu', params).then(
      res => {
        resolve(res)
      },
      err => {
        reject(err)
      }
    )
  })

}

//  获取所有菜单列表
export const allList = (params) => {
  return http.fetchGet('admin/menu/getAllList', params)
}

//  创建
export const create = (params) => {
  return http.fetchPost('admin/menu', params)
}
//  获取详情
export const detail = (id) => {
  return http.fetchGet('admin/menu/detail/' + id)
}
//  更新
export const update = (id, params) => {
  return http.fetchPut('admin/menu/' + id, params)
}
//  删除
export const del = (id) => {
  return http.fetchDelete('admin/menu/' + id)
}

//  获取菜单类型
export const getMenuTypeList = (params) => {
  return http.fetchGet('admin/menu/getMenuTypeList', params)
}

//  获取菜单Tree列表
export const getMenuListTree = (params) => {
  return http.fetchGet('admin/menu/getMenuListTree', params)
}
let dataApi = {
  list: pageList,
  allList: allList,
  create: create,
  detail: detail,
  update: update,
  del: del,
  getMenuTypeList: getMenuTypeList,
  getMenuListTree: getMenuListTree
}
export default dataApi
